package com.eims.sls_app.fragment;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.alibaba.fastjson.JSON;
import com.android.volley.Request;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.RequestParams;
import com.contans.view.HallDanduanInfoVo;
import com.contans.view.HallJJInfoVo;
import com.contans.view.PageIndicatorView;
import com.contans.view.PayFroresultVo;
import com.eims.sls_app.dataaccess.DtMatch;
import com.eims.sls_app.dataaccess.DtMatchBJDC;
import com.eims.sls_app.dataaccess.DtMatch_Basketball;
import com.eims.sls_app.dataaccess.ImageViews;
import com.eims.sls_app.dataaccess.Lottery;
import com.eims.sls_app.dataaccess.SelectedNumbers;
import com.eims.sls_app.dataaccess.utils.HttpUtils;
import com.eims.sls_app.dialog.HallDanguanPaySureDialog;
import com.eims.sls_app.protocol.MD5;
import com.eims.sls_app.protocol.RspBodyBaseBean;
import com.eims.sls_app.ui.AmountOfCharge;
import com.eims.sls_app.ui.Buy_DLT_Activit;
import com.eims.sls_app.ui.Buy_RX9_Activit;
import com.eims.sls_app.ui.Buy_SFC_Activity;
import com.eims.sls_app.ui.ConfirmselectionActivity;
import com.eims.sls_app.ui.CustomerActivity;
import com.eims.sls_app.ui.FollowActivity;
import com.eims.sls_app.ui.HallDanguanPaySuccessActivity;
import com.eims.sls_app.ui.LoginActivity;
import com.eims.sls_app.ui.LuckyCenterActivity;
import com.eims.sls_app.ui.MainActivity;
import com.eims.sls_app.ui.PaySuccessActivity;
import com.eims.sls_app.ui.SelectNumberActivity;
import com.eims.sls_app.ui.SelectNumberActivityFC3D;
import com.eims.sls_app.ui.SelectNumberActivityPL3;
import com.eims.sls_app.ui.SelectNumberActivityPL5_QXC;
import com.eims.sls_app.ui.SelectRechargeTypeActivity;
import com.eims.sls_app.ui.Select_11X5Activity;
import com.eims.sls_app.ui.Select_QlcActivity;
import com.eims.sls_app.ui.Select_SSCActivity;
import com.eims.sls_app.ui.Select_bjdcActivity;
import com.eims.sls_app.ui.Select_jclqActivity;
import com.eims.sls_app.ui.Select_jczqActivity;
import com.eims.sls_app.ui.Select_k3Activity;
import com.eims.sls_app.ui.SettingActivity;
import com.eims.sls_app.ui.adapter.PageAdapter;
import com.eims.sls_app.utils.App;
import com.eims.sls_app.utils.AppTools;
import com.eims.sls_app.utils.BaseHelper;
import com.eims.sls_app.utils.ImageManager;
import com.eims.sls_app.utils.LotteryUtils;
import com.eims.sls_app.utils.MyPushTask;
import com.eims.sls_app.utils.NetWork;
import com.eims.sls_app.utils.RequestUtil;
import com.eims.sls_app.utils.RoundImageView;
import com.eims.sls_app.view.MyToast;
import com.eims.sls_app.view.PullToRefreshView;
import com.eims.sls_app.view.PullToRefreshView.OnHeaderRefreshListener;
import com.eims.sls_app.viewpager.AutoLoopViewPager;
import com.eims.sls_app.viewpager.CirclePageIndicator;
import com.google.gson.Gson;
import com.listener.OnHallDanguanPaySureListener;
import com.listener.OnHallDanguanpositionPaySureListener;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.Html;
import android.text.Spanned;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import bls.juejin.cn.R;

/**
 * * 大厅
 */
@SuppressLint({"NewApi", "DefaultLocale"})
public class HallFragment extends Fragment implements OnClickListener, OnHeaderRefreshListener,
        OnHallDanguanPaySureListener, OnHallDanguanpositionPaySureListener {

    public View v;
    private ImageView mIvIconService;

    private SharedPreferences settings;// 保存购彩大厅彩种id位置
    private static final String TAG = "HallFragment";
    public static String Message;

    private PullToRefreshView mPullToRefreshView;

    // private Button btn_luck;
    public static List<Lottery> listLottery;
    public static boolean refreType = true;
    private Context context;

    private Intent intent;
    private MainActivity activity;
    private List<RequestUtil> requestUtils;
    private List<Integer> menuList = new ArrayList<Integer>();
    private AutoLoopViewPager loopView;
    private ArrayList<ImageViews> imageviews;// 广告条数据
    private CirclePageIndicator indy;
    private String auth;
    private String opt, info, time, imei, crc;

    private String getauth;
    private String getopt, getinfo, gettime, getimei, getcrc;

    private String getDanguanauth;
    private String getDanguanopt, getDanguaninfo, getDanguantime, getDanguanimei, getDanguancrc;

    private RelativeLayout rlJczq;
    private LinearLayout lrJclq, lrDlt, lrJczq_dg, lrSfc, lrR9;
    private LinearLayout lrk3, lrg11x5, lr11x5, lrSSC, lrBjdc;
    private LinearLayout lrFollow, lrHotZx, lrBf;
    private MyHandler mHandler;

    List<HallJJInfoVo> hallInfoList;
    private java.text.DecimalFormat df;

    private TextView tvHallInfo;

    private Button btnPayOk;
    private HallDanguanPaySureDialog PaySureDialog;

    private MyDanguanHandler myDanguanHandler;
    private GetinfoMyHandler getinfoMyHandler;

    // public HallDanduanInfoVo hallDanganInfoVo;

    private LinearLayout lrHallDanguanShow;
    private TextView tvStopTime, tvmainTeam, tvguestTeam, tvPingTeam, tvspfwin, tvspfflat, tvspflose, tvzs;
    private ImageView ivMainTeam, ivGuestTeam, ivTuijian_01, ivTuijian_02, ivTuijian_03, ivTuijian_04, ivTuijian_05;
    private ImageView ivDuijian_01, ivDuijian_02, ivDuijian_03;
    private RelativeLayout rlChoice_01, rlChoice_02, rlChoice_03;

    private boolean ischoice_01 = false;
    private boolean ischoice_02 = false;
    private boolean ischoice_03 = false;

    private ProgressDialog pd;

    public List<SelectedNumbers> getDanguanList;

    private HallDanguanMyHandler hallmyDanguanHandler;
    private String SucJinECost, SucCaiJinCost, SuccMoney;
    private DecimalFormat format = new DecimalFormat("#####0.00");

    public int numChoice;
    public double allMoney;
    private int payPosition = 0;
    String strJJMoney;

    public String resultMsg;
    public Double dbbalance, dbfreeze;
    public String schemeId;
    private Gallery gallery;
    public PageAdapter pageAdapter;
    List<HallDanduanInfoVo> listHunhDanguan;

    private RelativeLayout rlDanGuanShow;

    private PageIndicatorView pageIndor;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i(TAG, "onCreate");
        // setHasOptionsMenu(true);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Log.i(TAG, "onCreateView");
        if (v == null) {
            v = inflater.inflate(R.layout.activity_hall_new_3_6, container, false);
        }
        mHandler = new MyHandler();
        myDanguanHandler = new MyDanguanHandler();
        hallmyDanguanHandler = new HallDanguanMyHandler();
        // getinfoMyHandler=new GetinfoMyHandler();
        init();
        findView(v);
        setListener();

        Log.e("listLottery", "listLottery" + listLottery);
        return v;
    }

    /**
     * 初始化
     */
    private void init() {
        df = new java.text.DecimalFormat("#.00");
        context = getActivity();
        listLottery = getData();
        // getLotteryData();
        activity = (MainActivity) getActivity();
    }

    private void findView(View v) {
        gallery = (Gallery) v.findViewById(R.id.gallery1);
        pageIndor = (PageIndicatorView) v.findViewById(R.id.pageView);
        rlDanGuanShow = (RelativeLayout) v.findViewById(R.id.rl_danguan_show);
        tvHallInfo = (TextView) v.findViewById(R.id.hall_tv_info);
        rlJczq = (RelativeLayout) v.findViewById(R.id.hall_lr_seletct_bet_zjcq);
        lrJclq = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_zjlq);
        lrDlt = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_dlt);
        lrJczq_dg = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_zjcq_dg);
        lrSfc = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_zjcq_sfc);
        lrR9 = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_r9);

        lrFollow = (LinearLayout) v.findViewById(R.id.fragment_hall_lr_follow);
        lrHotZx = (LinearLayout) v.findViewById(R.id.fragment_hall_lr_hot_info);
        lrBf = (LinearLayout) v.findViewById(R.id.fragment_hall_lr_bf);

        mIvIconService = (ImageView) v.findViewById(R.id.iv_icon_service);
        imageviews = new ArrayList<ImageViews>();

        btnPayOk = (Button) v.findViewById(R.id.hall_lr_danguan_btn_pay);

        mPullToRefreshView = (PullToRefreshView) v.findViewById(R.id.mPullToRefreshView);

        lrHallDanguanShow = (LinearLayout) v.findViewById(R.id.hall_lr_danguan_show);
        ;
        tvStopTime = (TextView) v.findViewById(R.id.hall_lr_danguan_tv_time);
        tvmainTeam = (TextView) v.findViewById(R.id.rl_duiwu_01_tv_duiwu);
        tvguestTeam = (TextView) v.findViewById(R.id.rl_duiwu_03_tv_duiwu);
        tvPingTeam = (TextView) v.findViewById(R.id.rl_duiwu_02_tv_duiwu);
        tvspfwin = (TextView) v.findViewById(R.id.rl_duiwu_01_tv_peilv);
        tvspfflat = (TextView) v.findViewById(R.id.rl_duiwu_02_tv_peilv);
        tvspflose = (TextView) v.findViewById(R.id.rl_duiwu_03_tv_peilv);
        tvzs = (TextView) v.findViewById(R.id.hall_lr_danguan_tv_tuijian_num);

        ivMainTeam = (ImageView) v.findViewById(R.id.hall_rl_tv_gaunahu_thui_01);
        ivGuestTeam = (ImageView) v.findViewById(R.id.hall_rl_tv_gaunahu_thui_02);
        ivTuijian_01 = (ImageView) v.findViewById(R.id.hall_lr_danguan_iv_01);
        ivTuijian_02 = (ImageView) v.findViewById(R.id.hall_lr_danguan_iv_02);
        ivTuijian_03 = (ImageView) v.findViewById(R.id.hall_lr_danguan_iv_03);
        ivTuijian_04 = (ImageView) v.findViewById(R.id.hall_lr_danguan_iv_04);
        ivTuijian_05 = (ImageView) v.findViewById(R.id.hall_lr_danguan_iv_05);

        ivDuijian_01 = (ImageView) v.findViewById(R.id.rl_duiwu_01_iv_duiwu);
        ivDuijian_02 = (ImageView) v.findViewById(R.id.rl_duiwu_02_iv_duiwu);
        ivDuijian_03 = (ImageView) v.findViewById(R.id.rl_duiwu_03_iv_duiwu);
        rlChoice_01 = (RelativeLayout) v.findViewById(R.id.rl_duiwu_01);
        rlChoice_02 = (RelativeLayout) v.findViewById(R.id.rl_duiwu_02);
        rlChoice_03 = (RelativeLayout) v.findViewById(R.id.rl_duiwu_03);


        lrk3 = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_jiangsu);
        lrg11x5 = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_zjcq_11of5);
        lr11x5 = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_11yun);
        lrSSC = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_chongqing);

        lrBjdc = (LinearLayout) v.findViewById(R.id.hall_lr_seletct_bet_bjdc);

        /*
         * if (listLottery != null && listLottery.size() > 0) { gvAdapter = new
         * GridView_HallLotteryAdapter(context, listLottery); } else { gvAdapter = new
         * GridView_HallLotteryAdapter(context, getData()); }
         */
        // gv_hall_lottry.setAdapter(gvAdapter);
        // gv_hall_lottry.setFocusable(false);

        mPullToRefreshView.setOnHeaderRefreshListener(this);

        // btn_luck = (Button) v.findViewById(R.id.btn_luckyBtn);
        loopView = (AutoLoopViewPager) v.findViewById(R.id.autoLoop);
        indy = (CirclePageIndicator) v.findViewById(R.id.indy);

        /** 要更改的 **/
        menuList.add(R.drawable.menu_refresh_change);
        menuList.add(R.drawable.menu_setting_change);
        menuList.add(R.drawable.menu_changeuser_change);
        menuList.add(R.drawable.menu_exit_change);

        if (NetWork.isConnect(context)) {
            if (null == requestUtils)
                requestUtils = new ArrayList<RequestUtil>();
            getLotteryData();// 获取彩种信息
            doAutoLogin();// 自动登录
            LoadImageview();
            // loadInfoview();
        } else {
            MyToast.getToast(context, "网络连接异常，请检查网络").show();
            MainActivity.ll_main.setVisibility(View.GONE);
            if (App.showZongjiangInfo != null) {
                tvHallInfo.setText(App.showZongjiangInfo);
            } else {
                tvHallInfo.setText("数据加载中");
            }
        }
        // pageIndor.setTotalPage(8);
        // Set the adapter to our custom adapter (below)
        gallery.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                pageIndor.setCurrentPage(arg2);
                // Toast.makeText(Gallery1.this, "select" + arg2, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub

            }
        });
    }

    private void LoadImageview() {
        imageviews.clear();
        MyAsynTask3 asynTask3 = new MyAsynTask3();
        asynTask3.execute();
    }

    private void loadInfoview() {
        getJiangjinAsynTask jiangjinAsynTask = new getJiangjinAsynTask();
        jiangjinAsynTask.execute();
    }

    private void loadDanguanInfoview() {
        getDanguanAsynTask danguanAsynTask = new getDanguanAsynTask();
        danguanAsynTask.execute();
    }

    private void getInfoMyview() {
        if (App.user != null) {
            GetinfoMyAsynTask getinfoMyAsynTask = new GetinfoMyAsynTask();
            getinfoMyAsynTask.execute();
        }

    }

    /**
     * 绑定监听
     */
    private void setListener() {

        rlJczq.setOnClickListener(this);
        lrJclq.setOnClickListener(this);
        lrDlt.setOnClickListener(this);
        lrJczq_dg.setOnClickListener(this);
        lrSfc.setOnClickListener(this);
        lrR9.setOnClickListener(this);
        lrFollow.setOnClickListener(this);
        lrHotZx.setOnClickListener(this);
        lrBf.setOnClickListener(this);
        rlChoice_01.setOnClickListener(this);
        rlChoice_02.setOnClickListener(this);
        rlChoice_03.setOnClickListener(this);
        btnPayOk.setOnClickListener(this);

        // btn_luck.setOnClickListener(this);
        mIvIconService.setOnClickListener(this);


        lrk3.setOnClickListener(this);
        lrg11x5.setOnClickListener(this);
        lr11x5.setOnClickListener(this);
        lrSSC.setOnClickListener(this);
        lrBjdc.setOnClickListener(this);

        ;
    }

    public String formateRate(String rateStr) {
        if (rateStr.indexOf(".") != -1) {
            // 获取小数点的位置
            int num = 0;
            num = rateStr.indexOf(".");

            // 获取小数点后面的数字 是否有两位 不足两位补足两位
            String dianAfter = rateStr.substring(0, num + 1);
            String afterData = rateStr.replace(dianAfter, "");
            if (afterData.length() < 2) {
                afterData = afterData + "0";
            } else {
                afterData = afterData;
            }
            return rateStr.substring(0, num) + "." + afterData.substring(0, 2);
        } else {
            if (rateStr == "1") {
                return "100";
            } else {
                return rateStr;
            }
        }
    }

    // public String GetYujiJJMoney() {
    // allMoney = 0.0;
    // numChoice = 0;
    //
    // String info = "";
    // if (ischoice_01) {
    // if (allMoney >= (100 * Double.parseDouble(hallDanganInfoVo.getSpfwin()))) {
    //
    // } else {
    // allMoney = 100 * Double.parseDouble(hallDanganInfoVo.getSpfwin());
    //
    // }
    //
    // numChoice = numChoice + 1;
    //
    // }
    // if (ischoice_02) {
    // if (allMoney >= (100 * Double.parseDouble(hallDanganInfoVo.getSpfflat()))) {
    //
    // } else {
    // allMoney = 100 * Double.parseDouble(hallDanganInfoVo.getSpfflat());
    // }
    // numChoice = numChoice + 1;
    // }
    // if (ischoice_03) {
    // if (allMoney >= (100 * Double.parseDouble(hallDanganInfoVo.getSpflose()))) {
    //
    // } else {
    // allMoney = 100 * Double.parseDouble(hallDanganInfoVo.getSpflose());
    // Log.e("xx", Double.parseDouble(hallDanganInfoVo.getSpfwin()) + "");
    // }
    //
    // numChoice = numChoice + 1;
    // }
    //
    // if (numChoice == 0) {
    // info = "投0元变" + formateRate(allMoney + "") + "元";
    // } else if (numChoice == 1) {
    // info = "投100元变" + formateRate(allMoney + "") + "元";
    // } else if (numChoice == 2) {
    // info = "投200元变" + formateRate(allMoney + "") + "元";
    // } else if (numChoice == 3) {
    // info = "投300元变" + formateRate(allMoney + "") + "元";
    // }
    // strJJMoney = formateRate(allMoney + "");
    // return info;
    // }

    public void getlistDanguanInfo() {
        SelectedNumbers numbers = new SelectedNumbers();

        String strChoiceInfo = "";
        if (ischoice_01) {
            if (strChoiceInfo.equals("")) {
                strChoiceInfo = "1";
            } else {
                strChoiceInfo = strChoiceInfo + ",1";
            }

        }
        if (ischoice_02) {
            if (strChoiceInfo.equals("")) {
                strChoiceInfo = "2";
            } else {
                strChoiceInfo = strChoiceInfo + ",2";
            }
        }
        if (ischoice_03) {
            if (strChoiceInfo.equals("")) {
                strChoiceInfo = "3";
            } else {
                strChoiceInfo = strChoiceInfo + ",3";
            }
        }

        numbers.setType(0);
        numbers.setCount(new Long((long) numChoice));
        numbers.setMoney(new Long((long) numChoice * 100));
        numbers.setPlayType(7207);
        numbers.setFlag(false);
        numbers.setLotteryNumber(
                "7207;[" + listHunhDanguan.get(payPosition).getMatchId() + "(" + strChoiceInfo + ")];[A01]");
        getDanguanList = new ArrayList<SelectedNumbers>();
        getDanguanList.add(numbers);

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            // case R.id.rl_duiwu_01:
            //
            // ischoice_01 = !ischoice_01;
            // if (ischoice_01) {
            // rlChoice_01.setBackgroundResource(R.drawable.lr_danguan_input_border_on);
            // tvmainTeam.setTextColor(getResources().getColor(R.color.white));
            // tvspfwin.setTextColor(getResources().getColor(R.color.white));
            // } else {
            // rlChoice_01.setBackgroundResource(R.drawable.lr_danguan_input_border);
            // tvmainTeam.setTextColor(getResources().getColor(R.color.hall_danguan_team_bg));
            // tvspfwin.setTextColor(getResources().getColor(R.color.hall_danguan_peiiv_bg));
            // }
            // btnPayOk.setText(GetYujiJJMoney());
            // break;
            // case R.id.rl_duiwu_02:
            // ischoice_02 = !ischoice_02;
            // if (ischoice_02) {
            // rlChoice_02.setBackgroundResource(R.drawable.lr_danguan_input_border_on);
            // tvPingTeam.setTextColor(getResources().getColor(R.color.white));
            // tvspfflat.setTextColor(getResources().getColor(R.color.white));
            // } else {
            // rlChoice_02.setBackgroundResource(R.drawable.lr_danguan_input_border);
            // tvPingTeam.setTextColor(getResources().getColor(R.color.hall_danguan_team_bg));
            // tvspfflat.setTextColor(getResources().getColor(R.color.hall_danguan_peiiv_bg));
            // }
            // btnPayOk.setText(GetYujiJJMoney());
            // break;
            // case R.id.rl_duiwu_03:
            // ischoice_03 = !ischoice_03;
            // if (ischoice_03) {
            // rlChoice_03.setBackgroundResource(R.drawable.lr_danguan_input_border_on);
            // tvguestTeam.setTextColor(getResources().getColor(R.color.white));
            // tvspflose.setTextColor(getResources().getColor(R.color.white));
            // } else {
            // rlChoice_03.setBackgroundResource(R.drawable.lr_danguan_input_border);
            // tvguestTeam.setTextColor(getResources().getColor(R.color.hall_danguan_team_bg));
            // tvspflose.setTextColor(getResources().getColor(R.color.hall_danguan_peiiv_bg));
            // }
            // btnPayOk.setText(GetYujiJJMoney());
            // break;
            // case R.id.hall_lr_danguan_btn_pay:
            // if (null == AppTools.user) {
            // Toast.makeText(getActivity(), "未登录请先登录！", Toast.LENGTH_SHORT).show();
            // intent = new Intent(context, LoginActivity.class);
            // startActivity(intent);
            // } else {
            //
            // if (ischoice_01 || ischoice_02 || ischoice_03) {
            // getlistDanguanInfo(ischoice_01,ischoice_01,ischoice_01,payPosition,numChoice);
            // PaySureDialog = new HallDanguanPaySureDialog(context, this, numChoice * 100 +
            // "");
            // Window window = PaySureDialog.getWindow();
            // // 可以在此设置显示动画
            // WindowManager.LayoutParams wl = window.getAttributes();
            // wl.x = 0;
            // wl.y = activity.getWindowManager().getDefaultDisplay().getHeight();
            // // 以下这两句是为了保证按钮可以水平满屏
            // wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
            // wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            //
            // window.setWindowAnimations(R.style.mystyle); // 添加动画
            // // 设置显示位置
            // PaySureDialog.onWindowAttributesChanged(wl);
            //
            // PaySureDialog.setCanceledOnTouchOutside(true);// 点击其他区域dialog消失
            // PaySureDialog.show();
            // } else {
            // Toast.makeText(getActivity(), "至少选择一项单关！", Toast.LENGTH_SHORT).show();
            // }
            // }

            // break;


            case R.id.hall_lr_seletct_jiangsu:
                if (listLottery == null) {
                    listLottery = getData();
                }

                App.lottery = listLottery.get(4);
                if (App.lottery.getLotteryID().equals("83")) {
                    // if(App.lottery.getIsSale().equals("true")){
                    Intent intent3 = new Intent(context, Select_k3Activity.class);
                    startActivity(intent3);
                }

                break;
            case R.id.hall_lr_seletct_bet_zjcq_11of5:
                if (listLottery == null) {
                    listLottery = getData();
                }
                itemOnclick(3);
                break;
            case R.id.hall_lr_seletct_bet_11yun:

                if (listLottery == null) {
                    listLottery = getData();
                }
                App.lottery = listLottery.get(5);
                if (App.lottery.getLotteryID().equals("62")) {

                    //Log.e("11X5", App.lottery.getIsSale());
                    intent = new Intent(context, Select_11X5Activity.class);
                    startActivity(intent);
                }

                break;
            case R.id.hall_lr_seletct_chongqing:
                if (listLottery == null) {
                    listLottery = getData();
                }
                App.lottery = listLottery.get(2);
                if (App.lottery.getLotteryID().equals("28")) {


                    Intent intent2 = new Intent(context, Select_SSCActivity.class);
                    startActivity(intent2);
                }
                break;


            case R.id.iv_icon_service:
                Intent intent = new Intent(getActivity(), CustomerActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_zq_lottery_football:
                // AppTools.lottery = listLottery.get(0);
                refreType = true;
                getBallData(getActivity(), 0);
                break;
            case R.id.ll_lq_lottery_basketball:
                // AppTools.lottery = listLottery.get(1);
                refreType = true;
                getBasketball(getActivity(), 0);
                break;
            case R.id.hall_lr_seletct_bet_zjcq:
                refreType = true;
                getBallData(getActivity(), 0);
                break;
            case R.id.hall_lr_seletct_bet_zjlq:
                refreType = true;
                getBasketball(getActivity(), 0);
                break;
            case R.id.hall_lr_seletct_bet_bjdc:
//                itemOnclick(8);
//                Toast.makeText(getActivity(), "暂停销售", Toast.LENGTH_SHORT).show();

                if (listLottery == null) {
                    listLottery = getData();
                }
//
//                Lottery lottery=new Lottery();
//                lottery.setLotteryID("45");
//                lottery.setLotteryName("北京单场");
//                listLottery.add(lottery);
                Log.e("listLottery", "listLottery" + listLottery);
                for (int i = 0; i < listLottery.size(); i++) {
                    Log.e("listLottery", i + "," + listLottery.get(i).getLotteryID() + "," + listLottery.get(i).getLotteryName());
                }

                itemOnclick(9);
//
                break;
            case R.id.hall_lr_seletct_bet_dlt:

                Toast.makeText(getActivity(), "暂停销售", Toast.LENGTH_SHORT).show();

//                if (listLottery == null) {
//                    listLottery = getData();
//                }
////
//
//
//                itemOnclick(8);
//
                break;
            case R.id.hall_lr_seletct_bet_zjcq_dg:
                getBallData(getActivity(), 3);
                break;
            case R.id.hall_lr_seletct_bet_zjcq_sfc:
                Toast.makeText(getActivity(), "暂停销售", Toast.LENGTH_SHORT).show();
//                if (listLottery == null) {
//                    listLottery = getData();
//                }
//
//                App.lottery = listLottery.get(6);
//                if (App.lottery.getLotteryID().equals("74")) {
//
//                    intent = new Intent(context, Buy_SFC_Activity.class);// 胜负彩
//                    startActivity(intent);
//                }

                break;
            case R.id.hall_lr_seletct_bet_r9:
                Toast.makeText(getActivity(), "暂停销售", Toast.LENGTH_SHORT).show();
//                if (listLottery == null) {
//                    listLottery = getData();
//                }
//
//                App.lottery = listLottery.get(7);
//                if (App.lottery.getLotteryID().equals("75")) {
//                    // Log.e("RX9", AppTools.lottery.getIsSale());
//
//                    intent = new Intent(context, Buy_RX9_Activit.class);
//
//                    startActivity(intent);
//                }

                break;
            case R.id.fragment_hall_lr_follow:

                Intent intentFollow = new Intent(getActivity(), FollowActivity.class);
                startActivity(intentFollow);

                break;
            case R.id.fragment_hall_lr_hot_info:

                ((MainActivity) getActivity()).toLive(2);

                break;
            case R.id.fragment_hall_lr_bf:

                ((MainActivity) getActivity()).toLive(0);

                break;

        }
    }

    /**
     * 自动登录
     */
    public void doAutoLogin() {
        RequestUtil requestUtil = new RequestUtil(context, false, 0) {
            @Override
            public void responseCallback(JSONObject reponseJson) {

                String retult = AppTools.doLogin(reponseJson);

                if ("0".equals(retult)) {
                    SharedPreferences settings = context.getSharedPreferences("app_user", 0);
                    boolean isLogin = false;
                    String pass = "";
                    if (settings.contains("isLogin")) {
                        isLogin = settings.getBoolean("isLogin", false);
                    }
                    if (isLogin) {
                        // 判断是否有存 密码
                        if (settings.contains("pass")) {
                            pass = settings.getString("pass", null);
                        }
                    }
                    if (null != App.user)
                        App.user.setUserPass(pass);
                    if (RequestUtil.DEBUG)
                        Log.i(TAG, "自动登录成功...");
                    MyPushTask.newInstances(getActivity()).commit();
                } else {
                    if (RequestUtil.DEBUG)
                        Log.i(TAG, "自动登录失败" + retult);
                }
            }

            @Override
            public void responseError(VolleyError error) {
                if (RequestUtil.DEBUG)
                    Log.i(TAG, "自动登录失败" + error.getMessage());
            }
        };
        requestUtil.doAutoLogin();
        requestUtils.add(requestUtil);
    }

    /**
     * 得到竞彩 篮球数据
     */
    public void getBasketball(final Context context, final int position) {
        RequestUtil requestUtil = new RequestUtil(context, true, Request.CONFIG_CACHE_SHORT_60, true, "正在加载对阵...") {
            @Override
            public void responseCallback(JSONObject object2) {
                try {
                    if (null != object2) {
                        Log.i(TAG, "竞彩篮球的数据" + object2);
                        String error2 = object2.optString("error");
                        if ("0".equals(error2)) {
                            String detail2 = object2.optString("dtMatch");
                            String detail_singlepass2 = object2.optString("Singlepass");
                            if (detail2.length() == 0) {
                                Log.i("x", "无数据");
                            } else {
                                // 拿到对阵信息组
                                JSONArray array2 = new JSONArray(new JSONArray(detail2).toString());

                                List<List<DtMatch_Basketball>> listMatch = new ArrayList<List<DtMatch_Basketball>>();
                                for (int i = 0; i < array2.length(); i++) {
                                    JSONObject ob = array2.getJSONObject(i);
                                    String arr_4 = ob.optString("table4");
                                    String arr_l = ob.optString("table1");
                                    String arr2_l = ob.optString("table2");
                                    String arr3_l = ob.optString("table3");

                                    // 判断对阵 是否有

                                    listMatch.add(setList2(arr_l));

                                    listMatch.add(setList2(arr2_l));

                                    listMatch.add(setList2(arr3_l));
                                    listMatch.add(setList2(arr_4));
                                }

                                for (int i = 0; i < listLottery.size(); i++) {
                                    if ("73".equals(listLottery.get(i).getLotteryID())) {
                                        JSONArray array_single2 = new JSONArray(
                                                new JSONArray(detail_singlepass2).toString());

                                        List<List<DtMatch_Basketball>> listMatch_single = new ArrayList<List<DtMatch_Basketball>>();
                                        for (int j = 0; j < array_single2.length(); j++) {
                                            JSONObject ob = array_single2.getJSONObject(j);
                                            String arr_4 = ob.optString("table4");
                                            String arr_l = ob.optString("table1");
                                            String arr2_l = ob.optString("table2");
                                            String arr3_l = ob.optString("table3");

                                            // 判断对阵 是否有
                                            listMatch_single.add(setList2(arr_l));
                                            listMatch_single.add(setList2(arr2_l));
                                            listMatch_single.add(setList2(arr3_l));
                                            listMatch_single.add(setList2(arr_4));
                                        }
                                        App.DtMatch_Basketball = listMatch;
                                        App.DtMatch_Basketball_single = listMatch_single;
                                        App.lottery = listLottery.get(i);
                                        listLottery.get(i).setExplanation(object2.optString("explanation"));
                                    }
                                }
                            }

                            if (!checkBasketBallDtMatch_IsEmpty(App.DtMatch_Basketball,
                                    App.DtMatch_Basketball_single)) {
                                intent = new Intent(context, Select_jclqActivity.class);
                                intent.putExtra("position", position);
                                context.startActivity(intent);
                            } else
                                MyToast.getToast(context, "暂无篮球对阵信息...").show();

                        }
                    } else {
                        if (RequestUtil.DEBUG)
                            Log.i(TAG, "拿竞彩篮球数据为空");
                        MyToast.getToast(context, "抱歉,服务器异常,请稍后重试...").show();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    if (RequestUtil.DEBUG)
                        Log.i(TAG, "对阵获取失败，" + e.getMessage());
                    MyToast.getToast(context, "抱歉,数据获取错误...").show();
                }
            }

            @Override
            public void responseError(VolleyError error) {
                if (RequestUtil.DEBUG)
                    Log.e(TAG, "对阵获取失败，" + error.getMessage());
                MyToast.getToast(context, "抱歉,服务器异常,请稍后重试...").show();
            }
        };
        requestUtil.getJCData("73");
    }

    /**
     * 判断篮球对阵是否为空
     *
     * @param data        对阵信息
     * @param data_single 单关对阵信息
     * @return 判断结果 true为空 false不为空
     */
    public boolean checkBasketBallDtMatch_IsEmpty(List<List<DtMatch_Basketball>> data,
                                                  List<List<DtMatch_Basketball>> data_single) {
        boolean isEmpty = true;
        if (0 != data.size()) {
            for (int i = 0; i < data.size(); i++) {
                if (0 != data.get(i).size()) {
                    isEmpty = false;
                }
            }
        }
        if (0 != data_single.size()) {
            for (int i = 0; i < data_single.size(); i++) {
                if (0 != data_single.get(i).size()) {
                    isEmpty = false;
                }
            }
        }
        return isEmpty;
    }

    /**
     * 判断足球对阵是否为空
     *
     * @param data        对阵信息
     * @param data_single 单关对阵信息
     * @return 判断结果 true为空 false不为空
     */
    public boolean checkFootBallDtMatch_IsEmpty(List<List<DtMatch>> data, List<List<DtMatch>> data_single) {
        boolean isEmpty = true;
        if (0 != data.size() || data != null) {
            for (int i = 0; i < data.size(); i++) {
                if (0 != data.get(i).size()) {
                    isEmpty = false;
                }
            }
        }

        if (0 != data_single.size() || data_single != null) {
            for (int i = 0; i < data_single.size(); i++) {
                if (0 != data_single.get(i).size()) {
                    isEmpty = false;
                }
            }
        }
        return isEmpty;
    }

    /**
     * 篮球绑定数据 *
     */
    private List<DtMatch_Basketball> setList2(String arr) {
        List<DtMatch_Basketball> list_m = new ArrayList<DtMatch_Basketball>();
        if (arr.length() > 5) {
            JSONArray Arr;
            try {
                Arr = new JSONArray(arr);
                DtMatch_Basketball dtmatch = null;
                for (int j = 0; j < Arr.length(); j++) {
                    JSONObject item = Arr.getJSONObject(j);
                    dtmatch = new DtMatch_Basketball();
                    dtmatch.setMatchId(item.optString("matchId"));
                    dtmatch.setMatchNumber(item.optString("matchNumber"));
                    dtmatch.setMatchDate(item.optString("matchDate"));
                    dtmatch.setGame(item.getString("game"));
                    dtmatch.setGuestTeam(item.optString("guestTeam"));// 客队
                    dtmatch.setMainTeam(item.getString("mainTeam"));// 主队
                    dtmatch.setStopSellTime(item.optString("stopSellTime"));
                    dtmatch.setDay(item.optString("day"));
                    dtmatch.setMatchDate1(item.optString("matchDate1"));
                    dtmatch.setMainLose(item.getString("mainLose"));
                    dtmatch.setMainWin(item.getString("mainWin"));
                    dtmatch.setSmall(item.getString("small"));
                    dtmatch.setBigSmallScore(item.getString("bigSmallScore"));
                    dtmatch.setBig(item.getString("big"));
                    dtmatch.setLetScore(item.getString("letScore"));
                    dtmatch.setLetMainLose(item.getString("letMainLose"));
                    dtmatch.setLetMainWin(item.getString("letMainWin"));
                    dtmatch.setMatchDate2(item.getString("matchWeek"));
                    dtmatch.setDifferGuest1_5(item.optString("differGuest1_5"));
                    dtmatch.setDifferGuest6_10(item.optString("differGuest6_10"));
                    dtmatch.setDifferGuest11_15(item.optString("differGuest11_15"));
                    dtmatch.setDifferGuest16_20(item.optString("differGuest16_20"));
                    dtmatch.setDifferGuest21_25(item.optString("differGuest21_25"));
                    dtmatch.setDifferGuest26(item.optString("differGuest26"));
                    dtmatch.setDifferMain1_5(item.optString("differMain1_5"));
                    dtmatch.setDifferMain6_10(item.optString("differMain6_10"));
                    dtmatch.setDifferMain11_15(item.optString("differMain11_15"));
                    dtmatch.setDifferMain16_20(item.optString("differMain16_20"));
                    dtmatch.setDifferMain21_25(item.optString("differMain21_25"));
                    dtmatch.setDifferMain26(item.optString("differMain26"));
                    dtmatch.setSF(Boolean.parseBoolean(item.getString("isSF").toLowerCase()));
                    dtmatch.setDXF(Boolean.parseBoolean(item.getString("isDXF").toLowerCase()));
                    dtmatch.setRFSF(Boolean.parseBoolean(item.getString("isRFSF").toLowerCase()));
                    dtmatch.setSFC(Boolean.parseBoolean(item.getString("isSFC").toLowerCase()));
                    list_m.add(dtmatch);
                }
            } catch (Exception e) {
                e.printStackTrace();
                Log.i("x", "HallFragment错误" + e.getMessage());
            }
        }
        return list_m;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            /** 刷新 **/
            case 1:
                // getData();
                update();
                System.out.println("=================================在刷新方法里执行getData方法");
                break;
            /** 设置 **/
            case 2:
                intent = new Intent(context, SettingActivity.class);
                context.startActivity(intent);
                break;
            /** 更改账户 **/
            case 3:
                intent = new Intent(context, LoginActivity.class);
                intent.putExtra("loginType", "genggai");
                context.startActivity(intent);
                break;
            /** 退出 **/
            case 4:
                for (Activity activity : App.activityS) {
                    activity.finish();
                }
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        menu.clear();
        int sysVersion = Integer.parseInt(VERSION.SDK);
        if (sysVersion > 10) {
            menu.add(1, 1, 0, "刷新");
            menu.add(1, 2, 0, "设置");
            menu.add(1, 3, 0, "更换账户");
            menu.add(1, 4, 0, "退出");
        } else {
            menu.add(1, 1, 0, "").setIcon(R.drawable.menu_refresh_select);
            menu.add(1, 2, 0, "").setIcon(R.drawable.menu_setting_select);
            menu.add(1, 3, 0, "").setIcon(R.drawable.menu_changeuser_select);
            menu.add(1, 4, 0, "").setIcon(R.drawable.menu_exit_select);
        }
        super.onCreateOptionsMenu(menu, inflater);
    }

    /**
     * listView Item 的点击监听
     */
    class ItemsClickListener implements OnItemClickListener {
        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
            if (0 == listLottery.size() % 2) {
                itemOnclick(position);
            } else {
                if (listLottery.size() != position) {
                    itemOnclick(position);
                }
            }
        }
    }

    private void itemOnclick(int position) {
        /*
         * if (AppTools.allLotteryName.get("更多内容").equals("100")) {
         * MyToast.getToast(context, "该奖期已结束").show();
         *
         * }
         */

        // Log.i(TAG,"123123"+ AppTools.allLotteryLogo.get());
        long currentTime = System.currentTimeMillis();

        if (listLottery.size() > 0) {

            App.lottery = listLottery.get(position); // 对应id
            if (App.lottery.getIsuseId() != null && App.lottery.getIsuseId() != ""
                    && !"72".equals(App.lottery.getLotteryID()) && !"73".equals(App.lottery.getLotteryID())
                    && !"45".equals(App.lottery.getLotteryID())) {
                // if (!"72".equals(AppTools.lottery.getLotteryID())
                // && !"73".equals(AppTools.lottery.getLotteryID())
                // && !"45".equals(AppTools.lottery.getLotteryID())) {

                if (App.lottery.getLotteryID().equals("6")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    intent = new Intent(context, SelectNumberActivityFC3D.class);
                    // }else{
                    // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("63")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){

                    intent = new Intent(context, SelectNumberActivityPL3.class);
                    // }else{
                    // // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("3") || App.lottery.getLotteryID().equals("64")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    intent = new Intent(context, SelectNumberActivityPL5_QXC.class);
                    // }else{
                    // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("5")) {
                    Log.e("SSQ", App.lottery.getIsSale());
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    intent = new Intent(context, SelectNumberActivity.class);
                    // }else{
                    // // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("39")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    Log.e("DLT", App.lottery.getIsSale());
                    intent = new Intent(context, Buy_DLT_Activit.class);
                    // }else{
                    // // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("74")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    intent = new Intent(context, Buy_SFC_Activity.class);// 胜负彩
                    // }else{
                    // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("75")) {
                    Log.e("RX9", App.lottery.getIsSale());

                    // if(AppTools.lottery.getIsSale().equals("true")){
                    intent = new Intent(context, Buy_RX9_Activit.class);
                    // }else{
                    // // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }

                } else if (App.lottery.getLotteryID().equals("13")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    intent = new Intent(context, Select_QlcActivity.class);
                    // }else{
                    // // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("62") || App.lottery.getLotteryID().equals("70")
                        || App.lottery.getLotteryID().equals("78")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    Log.e("11X5", App.lottery.getIsSale());
                    intent = new Intent(context, Select_11X5Activity.class);
                    // }else{
                    // // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else if (App.lottery.getLotteryID().equals("28")) {

                    Log.e("SSC", App.lottery.getIsSale());
                    intent = new Intent(context, Select_SSCActivity.class);

                } else if (App.lottery.getLotteryID().equals("61")) {
                    MyToast.getToast(context, "此彩种暂停销售！").show();
                    return;

                } else if (App.lottery.getLotteryID().equals("83")) {
                    // if(AppTools.lottery.getIsSale().equals("true")){
                    intent = new Intent(context, Select_k3Activity.class);
                    // }else{
                    // // Toast.makeText(context, "暂停开售",
                    // Toast.LENGTH_SHORT).show();
                    // return;
                    // }
                } else {
                    MyToast.getToast(context, "正在开发").show();
                    return;
                }
                context.startActivity(intent);
            } else {
                refreType = true;
                if ("72".equals(App.lottery.getLotteryID())) {
                    // getBallData(getActivity());
                } else if ("73".equals(App.lottery.getLotteryID())) {
                    // getBasketball(getActivity());
                } else if ("45".equals(App.lottery.getLotteryID())) {
                    getBjdcData(getActivity());
                }
                // }else{
                // MyToast.getToast(context,"暂无对阵信息").show();
                // }
            }
//             && !"45".equals(listLottery.get(position).getLotteryID())
            if (!"73".equals(listLottery.get(position).getLotteryID())
                    && !"72".equals(listLottery.get(position).getLotteryID())) {
                if (listLottery.get(position).getDistanceTime() - currentTime <= 0) {

                    MyToast.getToast(context, "该奖期已结束，请等下一期").show();
                    return;
                }

            }
        }
    }

    /**
     * 得到竞彩 北单数据
     */
    public void getBjdcData(final Context context) {
        if (refreType) {
            RequestUtil requestUtil = new RequestUtil(context, false, // false
                    // 不需缓冲使用
                    Request.CONFIG_CACHE_SHORT, true, "正在加载对阵...") {
                @Override
                public void responseCallback(JSONObject object) {
                    try {
                        if (null != object) {
                            String error = object.optString("error");
                            if ("0".equals(error)) {
                                String detail = object.optString("dtMatch");
                                if (detail.length() == 0) {
                                    Log.i("x", "无数据");
                                } else {
                                    // 拿到对阵信息组
                                    JSONArray array = new JSONArray(new JSONArray(detail).toString());

                                    List<List<DtMatchBJDC>> listMatchbjdc = new ArrayList<List<DtMatchBJDC>>();

                                    for (int i = 0; i < array.length(); i++) {
                                        JSONObject ob = array.getJSONObject(i);

                                        String arr = ob.optString("table1");
                                        String arr2 = ob.optString("table2");
                                        String arr3 = ob.optString("table3");

                                        listMatchbjdc.add(setListbjdc(arr));
                                        listMatchbjdc.add(setListbjdc(arr2));
                                        listMatchbjdc.add(setListbjdc(arr3));
                                    }
                                    for (int i = 0; i < listLottery.size(); i++) {
                                        if ("45".equals(listLottery.get(i).getLotteryID())) {

                                            App.list_Matchs_bjdc = listMatchbjdc;
                                            App.lottery = listLottery.get(i);

                                            listLottery.get(i).setList_Matchs_bjdc(listMatchbjdc);
                                            listLottery.get(i).setExplanation(object.optString("explanation"));
                                        }
                                    }
                                }
                                if (!checkFootBjdc_IsEmpty(App.list_Matchs_bjdc)) {
                                    Log.e("listLottery", App.lottery.toString());
                                    intent = new Intent(context, Select_bjdcActivity.class);
                                    context.startActivity(intent);
                                } else
                                    MyToast.getToast(context, "暂无北单对阵信息...").show();
                            }
                        } else {
                            MyToast.getToast(context, "抱歉,服务器异常,请稍后重试...").show();
                            if (RequestUtil.DEBUG)
                                Log.i(TAG, "拿北单数据为空");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        MyToast.getToast(context, "抱歉,数据获取错误...").show();
                        if (RequestUtil.DEBUG)
                            Log.i(TAG, "对阵获取失败，" + e.getMessage());
                    }
                }

                @Override
                public void responseError(VolleyError error) {
                    MyToast.getToast(context, "抱歉,服务器异常,请稍后重试...").show();
                    if (RequestUtil.DEBUG)
                        Log.i(TAG, "对阵获取失败，" + error.getMessage());
                }
            };
            requestUtil.getJCData("45");
        }
    }

    public boolean checkFootBjdc_IsEmpty(List<List<DtMatchBJDC>> data) {
        boolean isEmpty = true;
        if (0 != data.size()) {
            for (int i = 0; i < data.size(); i++) {
                if (0 != data.get(i).size()) {
                    isEmpty = false;
                }
            }
        }

        return isEmpty;
    }

    /**
     * 将对阵信息绑定 *
     */
    @SuppressLint("DefaultLocale")
    private List<DtMatchBJDC> setListbjdc(String arr) {
        List<DtMatchBJDC> list_m = new ArrayList<DtMatchBJDC>();
        if (arr.length() > 6) {
            JSONArray Arr;
            try {
                Arr = new JSONArray(arr);
                DtMatchBJDC dtmatch = null;
                for (int j = 0; j < Arr.length(); j++) {
                    JSONObject item = Arr.getJSONObject(j);
                    dtmatch = new DtMatchBJDC();
                    dtmatch.setMatchId(item.optString("matchId"));
                    dtmatch.setMatchNumber(item.optString("matchNumber"));
                    dtmatch.setGame(item.getString("game"));
                    dtmatch.setGuestTeam(item.optString("guestTeam"));
                    dtmatch.setMainTeam(item.getString("mainTeam"));
                    // dtmatch.setSfloseball(item.getString("sflose"));//
                    // 胜负过关的让球数
                    dtmatch.setStopSellTime(item.optString("stopSellTime"));
                    // dtmatch.setTitle(item.optString("title"));
                    dtmatch.setTitle(item.optString("day"));
                    // System.out.println("=====title======="+item.optString("title"));
                    System.out.println("=====day=======" + item.optString("day"));
                    // dtmatch.setMainLoseBall(item.optInt("mainLoseBall"));
                    dtmatch.setMainLoseBall(item.optInt("giveBall"));
                    dtmatch.setMatchWeek(item.optString("matchWeek"));
                    /** 胜平负 */
                    dtmatch.setSpfwin(item.optString("winSp"));
                    dtmatch.setSpfflat(item.optString("flatSp"));
                    dtmatch.setSpflose(item.optString("loseSp"));

                    /** 上下单双 */
                    dtmatch.setUpdan(item.optString("shangDanSP"));
                    dtmatch.setUpshuang(item.optString("shangShuangSP"));
                    dtmatch.setDowndan(item.optString("xiaDanSP"));
                    dtmatch.setDownshuang(item.optString("xiaShuangSP"));

                    /** 胜负 */
                    // dtmatch.setSfggwin(item.optString("sfs"));
                    // dtmatch.setSfgglose(item.optString("sff"));

                    /** 猜比分 **/
                    dtmatch.setSother(item.getString("bfWinSqtSp"));
                    dtmatch.setS10(item.optString("bfWin10Sp"));
                    dtmatch.setS20(item.optString("bfWin20Sp"));
                    dtmatch.setS21(item.optString("bfWin21Sp"));
                    dtmatch.setS30(item.optString("bfWin30Sp"));
                    dtmatch.setS31(item.optString("bfWin31Sp"));
                    dtmatch.setS32(item.optString("bfWin32Sp"));
                    dtmatch.setS40(item.optString("bfWin40Sp"));
                    dtmatch.setS41(item.optString("bfWin41Sp"));
                    dtmatch.setS42(item.optString("bfWin42Sp"));
                    // dtmatch.setS50(item.optString("s50"));
                    // dtmatch.setS51(item.optString("s51"));
                    // dtmatch.setS52(item.optString("s52"));

                    dtmatch.setPother(item.getString("bfFlatPqtSp"));
                    dtmatch.setP00(item.getString("bfFlat00Sp"));
                    dtmatch.setP11(item.getString("bfFlat11Sp"));
                    dtmatch.setP22(item.getString("bfFlat22Sp"));
                    dtmatch.setP33(item.getString("bfFlat33Sp"));

                    dtmatch.setFother(item.getString("bfLoseFqtSp"));
                    dtmatch.setF01(item.getString("bfLose01Sp"));
                    dtmatch.setF02(item.getString("bfLose02Sp"));
                    dtmatch.setF12(item.getString("bfLose12Sp"));
                    dtmatch.setF03(item.getString("bfLose03Sp"));
                    dtmatch.setF13(item.getString("bfLose13Sp"));
                    dtmatch.setF23(item.getString("bfLose23Sp"));
                    dtmatch.setF04(item.getString("bfLose04Sp"));
                    dtmatch.setF14(item.getString("bfLose14Sp"));
                    dtmatch.setF24(item.getString("bfLose24Sp"));
                    // dtmatch.setF05(item.getString("f05"));
                    // dtmatch.setF15(item.getString("f15"));
                    // dtmatch.setF25(item.getString("f25"));

                    /** 半全场 **/
                    dtmatch.setSs(item.getString("bqcSsSp"));
                    dtmatch.setSp(item.getString("bqcSpSp"));
                    dtmatch.setSf(item.getString("bqcSfSp"));
                    dtmatch.setPs(item.getString("bqcPsSp"));
                    dtmatch.setPp(item.getString("bqcPpSp"));
                    dtmatch.setPf(item.getString("bqcPfSp"));
                    dtmatch.setFs(item.getString("bqcFsSp"));
                    dtmatch.setFp(item.getString("bqcFpSp"));
                    dtmatch.setFf(item.getString("bqcFfSp"));

                    /** 总进球 **/
                    dtmatch.setIn0(item.getString("zjq0"));
                    dtmatch.setIn1(item.getString("zjq1"));
                    dtmatch.setIn2(item.getString("zjq2"));
                    dtmatch.setIn3(item.getString("zjq3"));
                    dtmatch.setIn4(item.getString("zjq4"));
                    dtmatch.setIn5(item.getString("zjq5"));
                    dtmatch.setIn6(item.getString("zjq6"));
                    dtmatch.setIn7(item.getString("zjq7"));

                    dtmatch.setSFGG(true);
                    dtmatch.setSXDS(true);
                    dtmatch.setCBF(true);
                    dtmatch.setZJQ(true);
                    dtmatch.setNewSPF(true);
                    dtmatch.setBQC(true);
                    list_m.add(dtmatch);
                }
            } catch (Exception e) {
                e.printStackTrace();
                Log.i("x", "错误" + e.getMessage());
            }
        }
        return list_m;
    }

    /**
     * 获得所有彩种名称 以及 彩种ID
     */
    private List<Lottery> getData() {
        System.out.println("======================执行getData方法======================");
        if (listLottery == null)
            listLottery = new ArrayList<Lottery>();
        if (refreType) {
            // 清空数据
            listLottery.clear();
            Lottery lottery = null;
            Iterator iterator = null;
            System.out.println("执行getData方法" + App.allLotteryName.toString());
            if (null != App.allLotteryName) {
                iterator = App.allLotteryName.entrySet().iterator();
            }
            if (null != iterator)
                while (iterator.hasNext()) {
                    Map.Entry entry = (Map.Entry) iterator.next();
                    String key = entry.getKey().toString();
                    String value = entry.getValue().toString();
                    lottery = new Lottery();
                    lottery.setLotteryID(value);
                    lottery.setLotteryName(key);
                    listLottery.add(lottery);
                }
        }
        return listLottery;
    }

    /**
     * 后台获得所有cp信息
     */
    public void getLotteryData() {
        if (listLottery == null)
            listLottery = new ArrayList<Lottery>();

        if (refreType) {

            RequestUtil requestUtil = new RequestUtil(context, false, 0) {
                @Override
                public void responseCallback(JSONObject reponseJson) {
                    Log.e("后台所有彩排信息", reponseJson.toString());
                    String result = AppTools.getDate(reponseJson);
                    if ("0".equals(result)) {
                        update();
                        /** 是否第一次进入程序 不是的话就自动登录 */
                        if (App.index <= 1) {
                            App.isShow = false;
                            if (MainActivity.ll_main.getVisibility() == View.VISIBLE) {
                                MainActivity.ll_main
                                        .setAnimation(AnimationUtils.loadAnimation(context, android.R.anim.fade_out));
                                MainActivity.ll_main.setVisibility(View.GONE);
                            }
                            App.index++;
                            if (MainActivity.isWin) {
                                activity.toFindWininfo();
                            }
                        }
                    } else if ("-1001".equals(result)) {
                        if (RequestUtil.DEBUG) {
                            Log.e(TAG, "获取购彩大厅数据出错");
                        }
                        update();
                        /** 是否第一次进入程序 不是的话就自动登录 */
                        if (App.index <= 1) {
                            App.isShow = false;
                            // 让其在显示的时候才会出现动画
                            if (MainActivity.ll_main.getVisibility() == View.VISIBLE) {
                                MainActivity.ll_main
                                        .setAnimation(AnimationUtils.loadAnimation(context, android.R.anim.fade_out));
                                MainActivity.ll_main.setVisibility(View.GONE);
                            }
                            App.index++;
                            if (MainActivity.isWin) {
                                activity.toFindWininfo();
                            }
                        }
                        MyToast.getToast(context, "数据获取失败,请手动刷新").show();
                    }
                }

                @Override
                public void responseError(VolleyError error) {
                    Log.e(TAG, "出错了," + error.getMessage());
                    update();
                    /** 是否第一次进入程序 不是的话就自动登录 */
                    if (App.index <= 1) {
                        App.isShow = false;
                        if (MainActivity.ll_main.getVisibility() == View.VISIBLE) {
                            ((View) (MainActivity.ll_main))
                                    .setAnimation(AnimationUtils.loadAnimation(context, android.R.anim.fade_out));
                            MainActivity.ll_main.setVisibility(View.GONE);
                        }
                        App.index++;
                        if (MainActivity.isWin) {
                            activity.toFindWininfo();
                        }
                    }
                    MyToast.getToast(context, "数据获取失败,请手动刷新").show();
                }
            };
            requestUtil.getLotteryData(App.lotteryIds);
        }
    }

    /**
     * 跳到幸运数字页面
     */
    private void ToLuckActivity() {
        intent = new Intent(context, LuckyCenterActivity.class);
        context.startActivity(intent);
    }

    /**
     * 得到竞彩 足球 数据
     */
    public void getBallData(final Context context, final int position) {
        if (refreType) {

            RequestUtil requestUtil = new RequestUtil(context, true, Request.CONFIG_CACHE_SHORT_60, true,
                    "正在加载对阵...\n" + "对阵较多时加载会较慢...") {
                @Override
                public void responseCallback(JSONObject object) {
                    try {
                        if (null != object) {
                            Log.e(TAG, "得到竞彩足球的数据" + object);
                            String error = object.optString("error");
                            Log.e("BaseBall", error);
                            if ("0".equals(error)) {
                                String detail = object.optString("dtMatch");
                                String detail_singlepass = object.optString("Singlepass");
                                if (detail.length() == 0) {
                                    Log.i("x", "无数据");
                                } else {

                                    // 拿到对阵信息组
                                    JSONArray array = new JSONArray(new JSONArray(detail).toString());
                                    List<List<DtMatch>> listMatch = new ArrayList<List<DtMatch>>();
                                    for (int i = 0; i < array.length(); i++) {
                                        JSONObject ob = array.getJSONObject(i);
                                        for (int l = 1; l < 16; l++) {
                                            String arr = ob.optString("table" + l);
                                            listMatch.add(setList(arr));
                                        }
//                                        String arr = ob.optString("table1");
//                                        String arr2 = ob.optString("table2");
//                                        String arr3 = ob.optString("table3");
//                                        String arr4 = ob.optString("table4");
//                                        String arr5 = ob.optString("table5");
                                        // 判断对阵 是否有

//                                        listMatch.add(setList(arr));
//                                        listMatch.add(setList(arr2));
//                                        listMatch.add(setList(arr3));
//                                        listMatch.add(setList(arr4));


                                    }
                                    for (int i = 0; i < listLottery.size(); i++) {
                                        if ("72".equals(listLottery.get(i).getLotteryID())) {
                                            // 拿到单关对阵信息组
                                            JSONArray array_singlepass = new JSONArray(
                                                    new JSONArray(detail_singlepass).toString());
                                            List<List<DtMatch>> listMatch_singlepass = new ArrayList<List<DtMatch>>();
                                            for (int j = 0; j < array_singlepass.length(); j++) {
                                                JSONObject ob = array_singlepass.getJSONObject(j);


                                                for (int l = 1; l < 16; l++) {
                                                    String arr = ob.optString("table" + l);
                                                    if (!"".equals(arr)) {// 如果第一个不是空的
                                                        listMatch_singlepass.add(setList(arr));
                                                    }
                                                }
//												String arr = ob.optString("table1");
//												if (!"".equals(arr)) {// 如果第一个不是空的
//													listMatch_singlepass.add(setList(arr));
//												}
//												String arr2 = ob.optString("table2");
//												if (!"".equals(arr2)) {// 如果第二个不是空的
//													listMatch_singlepass.add(setList(arr2));
//												}
//												String arr3 = ob.optString("table3");
//												if (!"".equals(arr3)) {// 如果第三个不是空的
//													listMatch_singlepass.add(setList(arr3));
//												}
//												String arr4 = ob.optString("table4");
//												if (!"".equals(arr4)) {// 如果第一个不是空的
//													listMatch_singlepass.add(setList(arr4));
//												}
//												String arr5 = ob.optString("table5");
//												if (!"".equals(arr5)) {// 如果第一个不是空的
//													listMatch_singlepass.add(setList(arr5));
//												}
//												String arr6 = ob.optString("table6");
//												if (!"".equals(arr6)) {// 如果第一个不是空的
//													listMatch_singlepass.add(setList(arr6));
//												}String arr7 = ob.optString("table7");
//												if (!"".equals(arr7)) {// 如果第一个不是空的
//													listMatch_singlepass.add(setList(arr7));
//												}

                                            }
                                            App.list_singlepass_Matchs = listMatch_singlepass;
                                            App.list_Matchs = listMatch;
                                            listLottery.get(i).setExplanation(object.optString("explanation"));
                                            App.lottery = listLottery.get(i);
                                            System.out.println("+++++++++++++++listMatch_singlepass"
                                                    + listMatch_singlepass.size());
                                        }
                                    }
                                }

                                if (!checkFootBallDtMatch_IsEmpty(App.list_Matchs, App.list_singlepass_Matchs)) {
                                    intent = new Intent(context, Select_jczqActivity.class);
                                    intent.putExtra("isEmpty", false);
                                    intent.putExtra("position", position);
                                    context.startActivity(intent);
                                } else
                                    MyToast.getToast(context, "暂无足球对阵信息...").show();
                            }
                        } else {
                            MyToast.getToast(context, "抱歉,服务器异常,请稍后重试...").show();
                            if (RequestUtil.DEBUG)
                                Log.i(TAG, "拿竞彩足球数据为空");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        MyToast.getToast(context, "抱歉,数据获取错误...").show();
                        if (RequestUtil.DEBUG)
                            Log.i(TAG, "对阵获取失败，" + e.getMessage());
                    }
                }

                @Override
                public void responseError(VolleyError error) {
                    MyToast.getToast(context, "抱歉,服务器异常,请稍后重试...").show();
                    // if(RequestUtil.DEBUG)
                    Log.e(TAG, "对阵获取失败，" + error.getMessage());
                }
            };
            requestUtil.getJCData("72");
        }
    }

    /**
     * 将对阵信息绑定 *
     */
    @SuppressLint("DefaultLocale")
    private List<DtMatch> setList(String arr) {
        List<DtMatch> list_m = new ArrayList<DtMatch>();
        if (arr.length() > 5) {
            JSONArray Arr;
            try {
                Arr = new JSONArray(arr);
                DtMatch dtmatch = null;
                for (int j = 0; j < Arr.length(); j++) {
                    JSONObject item = Arr.getJSONObject(j);
                    dtmatch = new DtMatch();
                    dtmatch.setMatchId(item.optString("matchId"));
                    dtmatch.setMatchNumber(item.optString("matchNumber"));
                    dtmatch.setGame(item.getString("game"));
                    dtmatch.setGuestTeam(item.optString("guestTeam"));
                    dtmatch.setMainTeam(item.getString("mainTeam"));
                    dtmatch.setStopSellTime(item.optString("stopSellTime"));
                    dtmatch.setDay(item.optString("day"));
                    dtmatch.setMainLoseBall(item.optInt("mainLoseBall"));
                    dtmatch.setMatchWeek(item.optString("matchWeek"));
                    /** 胜平负 */
                    dtmatch.setSpfwin(item.optString("spfwin"));
                    dtmatch.setSpfflat(item.optString("spfflat"));
                    dtmatch.setSpflose(item.optString("spflose"));
                    /** 让球胜平负 */
                    dtmatch.setWin(item.optString("win"));
                    dtmatch.setFlat(item.optString("flat"));
                    dtmatch.setLose(item.optString("lose"));
                    dtmatch.setMatchDate(item.optString("matchDate"));
                    /** 猜比分 **/
                    dtmatch.setSother(item.getString("sother"));
                    dtmatch.setS10(item.optString("s10"));
                    dtmatch.setS20(item.optString("s20"));
                    dtmatch.setS21(item.optString("s21"));
                    dtmatch.setS30(item.optString("s30"));
                    dtmatch.setS31(item.optString("s31"));
                    dtmatch.setS32(item.optString("s32"));
                    dtmatch.setS40(item.optString("s40"));
                    dtmatch.setS41(item.optString("s41"));
                    dtmatch.setS42(item.optString("s42"));
                    dtmatch.setS50(item.optString("s50"));
                    dtmatch.setS51(item.optString("s51"));
                    dtmatch.setS52(item.optString("s52"));
                    dtmatch.setPother(item.getString("pother"));
                    dtmatch.setP00(item.getString("p00"));
                    dtmatch.setP11(item.getString("p11"));
                    dtmatch.setP22(item.getString("p22"));
                    dtmatch.setP33(item.getString("p33"));
                    dtmatch.setFother(item.getString("fother"));
                    dtmatch.setF01(item.getString("f01"));
                    dtmatch.setF02(item.getString("f02"));
                    dtmatch.setF12(item.getString("f12"));
                    dtmatch.setF03(item.getString("f03"));
                    dtmatch.setF13(item.getString("f13"));
                    dtmatch.setF23(item.getString("f23"));
                    dtmatch.setF04(item.getString("f04"));
                    dtmatch.setF14(item.getString("f14"));
                    dtmatch.setF24(item.getString("f24"));
                    dtmatch.setF05(item.getString("f05"));
                    dtmatch.setF15(item.getString("f15"));
                    dtmatch.setF25(item.getString("f25"));

                    /** 半全场 **/
                    dtmatch.setSs(item.getString("ss"));
                    dtmatch.setSp(item.getString("sp"));
                    dtmatch.setSf(item.getString("sf"));
                    dtmatch.setPs(item.getString("ps"));
                    dtmatch.setPp(item.getString("pp"));
                    dtmatch.setPf(item.getString("pf"));
                    dtmatch.setFs(item.getString("fs"));
                    dtmatch.setFp(item.getString("fp"));
                    dtmatch.setFf(item.getString("ff"));

                    /** 总进球 **/
                    dtmatch.setIn0(item.getString("in0"));
                    dtmatch.setIn1(item.getString("in1"));
                    dtmatch.setIn2(item.getString("in2"));
                    dtmatch.setIn3(item.getString("in3"));
                    dtmatch.setIn4(item.getString("in4"));
                    dtmatch.setIn5(item.getString("in5"));
                    dtmatch.setIn6(item.getString("in6"));
                    dtmatch.setIn7(item.getString("in7"));

                    dtmatch.setSPF(Boolean.parseBoolean(item.getString("isSPF").toLowerCase()));

                    Log.e(TAG, dtmatch.isSPF() + "");
                    dtmatch.setCBF(Boolean.parseBoolean(item.getString("isCBF").toLowerCase()));
                    dtmatch.setZJQ(Boolean.parseBoolean(item.getString("isZJQ").toLowerCase()));
                    dtmatch.setNewSPF(Boolean.parseBoolean(item.getString("isNewSPF").toLowerCase()));
                    dtmatch.setBQC(Boolean.parseBoolean(item.getString("isBQC").toLowerCase()));

                    list_m.add(dtmatch);
                }
            } catch (Exception e) {
                e.printStackTrace();
                Log.i("x", "错误" + e.getMessage());
            }
        }
        return list_m;

    }

    public void update() {

    }

    @Override
    public void onHeaderRefresh(PullToRefreshView view) {
        mPullToRefreshView.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (NetWork.isConnect(context)) {
                    refreType = true;
                    getLotteryData();
                    LoadImageview();
                    // loadInfoview();

                } else {
                    MyToast.getToast(context, "网络连接异常，请检查网络").show();
                    if (App.showZongjiangInfo != null) {
                        tvHallInfo.setText(App.showZongjiangInfo);
                    } else {
                        tvHallInfo.setText("数据加载中");
                    }
                }
                mPullToRefreshView.onHeaderRefreshComplete();
            }
        }, 1500);
    }

    /**
     * 取消所有请求
     */
    private void cancelAll() {
        if (null != requestUtils && 0 != requestUtils.size()) {
            int requestCount = requestUtils.size();
            for (int i = 0; i < requestCount; i++) {
                RequestUtil requestUtil = requestUtils.get(i);
                if (null != requestUtil) {
                    Request request = requestUtil.getRequest();
                    if (null != request)
                        request.cancel();
                }
            }
        }
    }

    @Override
    public void onResume() {
        Log.i(TAG, "onResume");
        super.onResume();
        // loadDanguanInfoview();
        update();
    }

    @Override
    public void onStop() {
        super.onStop();
        Log.i(TAG, "onStop");
        cancelAll();
    }

    @Override
    public void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        Log.i(TAG, "onDestroy");
        ViewGroup parent = (ViewGroup) v.getParent();
        if (parent != null) {
            parent.removeAllViews();
        }
    }

    @Override
    public void onDestroyView() {
        Log.i(TAG, "onDestroyView");
        super.onDestroyView();
    }

    class MyAsynTask3 extends AsyncTask<Integer, Integer, String> {
        String error = "0";

        @Override
        protected String doInBackground(Integer... params) {
            String key = MD5.md5(App.MD5_key);

            if (time == null) {
                time = RspBodyBaseBean.getTime();
            }
            if (imei == null) {
                imei = RspBodyBaseBean.getIMEI(context);
            }
            info = "";
            crc = RspBodyBaseBean.getCrc(time, imei, key, info, "-1");
            auth = RspBodyBaseBean.getAuth(crc, time, imei, "-1");
            String[] values = {"73", auth, info};
            String result = HttpUtils.doPost(App.names, values, App.path);
            if ("-500".equals(result))
                return "-500";

            try {
                Log.i("图片获取-----------result", result);
                JSONObject JSONObject = new JSONObject(result);
                error = JSONObject.optString("error");
                String msgstr = JSONObject.optString("msg");
                Message msg = handler.obtainMessage();
                if ("0".equals(error)) {
                    imageviews = (ArrayList<ImageViews>) JSON.parseArray(JSONObject.getJSONArray("picList").toString(),
                            ImageViews.class);
                    msg.what = 0;
                    handler.sendMessage(msg);
                } else {
                    msg.what = 2;
                    msg.obj = msgstr;
                    handler.sendMessage(msg);
                }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

            }
            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            // TODO Auto-generated method stub
            Message msg = handler.obtainMessage();
            msg.what = 500;
            handler.sendMessage(msg);
            super.onPostExecute(result);
            // handler.sendEmptyMessage(Integer.parseInt(result));
        }

    }

    @SuppressLint("HandlerLeak")
    private Handler handler = new Handler() {
        public void handleMessage(android.os.Message msg) {

            switch (msg.what) {
                case 0:
                    LocalAdp adapterLpp = new LocalAdp(context, imageviews);
                    loopView.setAdapter(adapterLpp);
                    adapterLpp.notifyDataSetChanged();
                    loopView.setBoundaryCaching(true);
                    loopView.setAutoScrollDurationFactor(10d);
                    loopView.setInterval(3000);
                    loopView.startAutoScroll();

                    indy.setViewPager(loopView);
                    indy.requestLayout();
                    break;
                case 2:
                    if (msg.obj != null) {
                        MyToast.getToast(context, String.valueOf(msg.obj));
                    }
                    break;
                case 500:

                    loadInfoview();
                    break;
                default:
                    break;
            }

        }
    };

    private static class LocalAdp extends PagerAdapter {
        private int count = 100;
        private Queue<View> views;
        private List<ImageViews> data;
        private LayoutInflater lay;
        private Context context;

        LocalAdp(Context ct, List<ImageViews> listNews) {
            views = new LinkedList<View>();
            data = listNews;
            lay = LayoutInflater.from(ct);
            context = ct;
        }

        @Override
        public int getCount() {
            if (data == null) {
                return 0;
            }
            return data.size();
        }

        @Override
        public boolean isViewFromObject(View arg0, Object arg1) {
            return arg0 == arg1;
        }

        @Override
        public Object instantiateItem(ViewGroup container, final int position) {
            View mage = views.poll();

            if (mage == null) {
                mage = lay.inflate(R.layout.item_image, null);
                mage.setId(count++);
            }
//            ImageView iv = (ImageView) mage.findViewById(R.id.mage);
            RoundImageView iv = (RoundImageView) mage.findViewById(R.id.mage);
            iv.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent intent = new Intent();
                    intent.setAction("android.intent.action.VIEW");

                    // TODO Auto-generated method stub
//                    if (position == 0) {
//                        // Toast.makeText(context, "0", Toast.LENGTH_SHORT).show();
//                        Uri content_url = Uri.parse("http://gundong.haoqiucai.com/HD2/JIAJIANG.HTML");
//                        intent.setData(content_url);
//                        context.startActivity(intent);
//                    } else if (position == 1) {
////						 Toast.makeText(context, "1", Toast.LENGTH_SHORT).show();
//                        Uri content_url = Uri.parse("http://8.ucaipiao.com/HD1/songcaijin.HTML");
//                        intent.setData(content_url);
//                        context.startActivity(intent);
//                    }
                }
            });
            /*
             * FIT_CONTER 安比例显示在中间
             */
            iv.setScaleType(ScaleType.FIT_XY);

            ImageManager.getInstance().displayImage(data.get(position).getPicUrl(), iv,
                    ImageManager.getViewsHeadOptions());

            container.addView(mage);
            return mage;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            View mage = (View) object;
            views.add(mage);
            Log.d("** des", mage.getId() + "  id" + " size " + views.size());
            container.removeView(mage);
        }

    }

    class getJiangjinAsynTask extends AsyncTask<Integer, Integer, String> {

        String error = "-1";

        @Override
        protected String doInBackground(Integer... params) {
            getinfo = "";
            getopt = "98";
            gettime = RspBodyBaseBean.getTime();
            getimei = RspBodyBaseBean.getIMEI(context);
            // info = RspBodyBaseBean.change_TheSun(schemeId+"", context_Sun);

            // String key = MD5.md5(App.user.getUserPass() +
            // App.MD5_key);
            String key = App.key;

            getcrc = RspBodyBaseBean.getCrc(gettime, getimei, key, getinfo, "");
            getauth = RspBodyBaseBean.getAuth(getcrc, gettime, getimei, "");

            String[] values = {getopt, getauth, getinfo};
            Log.i(TAG, "晒单" + RequestParams.convertParams(context, getopt, getinfo));
            String result = HttpUtils.doPost(App.names, values, App.path);
            System.out.println("晒单：" + result);

            if (result != null) {
                hallInfoList = new ArrayList<HallJJInfoVo>();
                error = "1";
                try {
                    JSONArray arr = new JSONArray(result);
                    for (int i = 0; i < arr.length(); i++) {
                        JSONObject temp = (JSONObject) arr.get(i);

                        HallJJInfoVo listShowValue = new HallJJInfoVo();
                        listShowValue.setName(temp.getString("Name"));
                        listShowValue.setWinMoney(temp.getString("WinMoney"));
                        Log.i(TAG, "晒单id" + listShowValue);

                        hallInfoList.add(listShowValue);

                    }

                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    error = "-1";
                    Log.e("x", "MyCenterActivity异常" + e.getMessage());
                }

            } else {
                error = "-1";
            }

            return error;
        }

        @Override
        protected void onPostExecute(String result) {

            mHandler.sendEmptyMessage(Integer.parseInt(result));

            super.onPostExecute(result);
        }
    }

    public String textinfo;

    @SuppressLint("HandlerLeak")
    class MyHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
            loadDanguanInfoview();
            switch (msg.what) {
                case 0:

                    break;
                case 1:

                    if (hallInfoList != null) {
                        textinfo = "";
                        if (hallInfoList.size() > 0) {
                            for (int i = 0; i < hallInfoList.size(); i++) {

                                final String name = hallInfoList.get(i).getName();
                                // String name = topicBeans.get(position).name;
                                final String isname;
                                if (isMobileNO(name)) {
                                    isname = name.substring(0, 3) + "****" + name.substring(7, name.length());
                                    // holder.tv_name.setText());
                                } else {
                                    isname = name;
                                    // holder.tv_name.setText(name.substring(0, 2)+"**");
                                }
                                if (i == 0) {
                                    textinfo = AppTools.changeStringColor("#000000", "恭喜")
                                            + AppTools.changeStringColor("#105cde", isname)
                                            + AppTools.changeStringColor("#000000", "竞彩命中")
                                            + AppTools.changeStringBoldColor("#e3393c",
                                            df.format(Double.parseDouble(hallInfoList.get(i).getWinMoney())))
                                            + AppTools.changeStringColor("#000000", "元");
                                } else {
                                    textinfo = textinfo
                                            + AppTools.changeStringColor("#000000", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;恭喜")
                                            + AppTools.changeStringColor("#105cde", isname)
                                            + AppTools.changeStringColor("#000000", "竞彩命中")
                                            + AppTools.changeStringBoldColor("#e3393c",
                                            df.format(Double.parseDouble(hallInfoList.get(i).getWinMoney())))
                                            + AppTools.changeStringColor("#000000", "元");
                                }

                            }
                            Spanned spanned2 = Html.fromHtml(textinfo);
                            App.showZongjiangInfo = spanned2;
                            tvHallInfo.setText(spanned2);
                        } else {
                            if (App.showZongjiangInfo != null) {
                                tvHallInfo.setText(App.showZongjiangInfo);
                            } else {
                                tvHallInfo.setText("数据加载中");
                            }

                        }

                    } else {

                    }

                    break;
                case -1:
                    if (App.showZongjiangInfo != null) {
                        tvHallInfo.setText(App.showZongjiangInfo);
                    } else {
                        tvHallInfo.setText("数据加载中");
                    }
                    break;
                case -500:

                    break;
                default:
                    break;
            }
            super.handleMessage(msg);
        }

    }

    class getDanguanAsynTask extends AsyncTask<Integer, Integer, String> {

        String error = "-1";

        @Override
        protected String doInBackground(Integer... params) {
            getDanguaninfo = "";
            getDanguanopt = "101";
            getDanguantime = RspBodyBaseBean.getTime();
            getDanguanimei = RspBodyBaseBean.getIMEI(context);
            // info = RspBodyBaseBean.change_TheSun(schemeId+"", context_Sun);

            // String key = MD5.md5(AppTools.user.getUserPass() +
            // AppTools.MD5_key);
            String key = App.key;

            getDanguancrc = RspBodyBaseBean.getCrc(getDanguantime, getDanguanimei, key, getDanguaninfo, "");
            getDanguanauth = RspBodyBaseBean.getAuth(getDanguancrc, getDanguantime, getDanguanimei, "");

            String[] values = {getDanguanopt, getDanguanauth, getDanguaninfo};
            Log.i(TAG, "晒单" + RequestParams.convertParams(context, getDanguanopt, getDanguaninfo));
            String result = HttpUtils.doPost(App.names, values, App.path);
            System.out.println("晒单：" + result);

            if (result != null) {
                if (result.equals("[]")) {
                    error = "-1";
                } else {
                    error = "1";
                    try {
                        listHunhDanguan = new ArrayList<HallDanduanInfoVo>();
                        JSONArray arr = new JSONArray(result);

                        // JSONObject temp = (JSONObject) arr.get(0);
                        // hallDanganInfoVo = new HallDanduanInfoVo();
                        //
                        // hallDanganInfoVo.setMatchId(temp.getString("matchId"));
                        // hallDanganInfoVo.setMatchNumber(temp.getString("matchNumber"));
                        // hallDanganInfoVo.setMatchWeek(temp.getString("matchWeek"));
                        // hallDanganInfoVo.setGame(temp.getString("game"));
                        // hallDanganInfoVo.setMainTeam(temp.getString("mainTeam"));
                        // hallDanganInfoVo.setGuestTeam(temp.getString("guestTeam"));
                        // hallDanganInfoVo.setSpfwin(temp.getString("spfwin"));
                        // hallDanganInfoVo.setSpfflat(temp.getString("spfflat"));
                        // hallDanganInfoVo.setSpflose(temp.getString("spflose"));
                        //
                        // hallDanganInfoVo.setSpf(temp.getString("spf"));
                        // hallDanganInfoVo.setZs(temp.getString("zs"));
                        // hallDanganInfoVo.setStoptime(temp.getString("stoptime"));

                        for (int i = 0; i < arr.length(); i++) {
                            JSONObject temp1 = (JSONObject) arr.get(i);
                            HallDanduanInfoVo ListhallDanganInfoVo = new HallDanduanInfoVo();

                            ListhallDanganInfoVo.setMatchId(temp1.getString("matchId"));
                            ListhallDanganInfoVo.setMatchNumber(temp1.getString("matchNumber"));
                            ListhallDanganInfoVo.setMatchWeek(temp1.getString("matchWeek"));
                            ListhallDanganInfoVo.setGame(temp1.getString("game"));
                            ListhallDanganInfoVo.setMainTeam(temp1.getString("mainTeam"));
                            ListhallDanganInfoVo.setGuestTeam(temp1.getString("guestTeam"));
                            ListhallDanganInfoVo.setSpfwin(temp1.getString("spfwin"));
                            ListhallDanganInfoVo.setSpfflat(temp1.getString("spfflat"));
                            ListhallDanganInfoVo.setSpflose(temp1.getString("spflose"));

                            ListhallDanganInfoVo.setSpf(temp1.getString("spf"));
                            ListhallDanganInfoVo.setZs(temp1.getString("zs"));
                            ListhallDanganInfoVo.setStoptime(temp1.getString("stoptime"));
                            listHunhDanguan.add(ListhallDanganInfoVo);
                        }
                        error = "3";

                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        error = "-1";
                        Log.e("x", "MyCenterActivity异常" + e.getMessage());
                    }
                }
            } else {
                error = "-1";
            }

            return error;
        }

        @Override
        protected void onPostExecute(String result) {

            myDanguanHandler.sendEmptyMessage(Integer.parseInt(result));

            super.onPostExecute(result);
        }
    }

    public void PayForlist() {
        if (listHunhDanguan != null) {
            if (listHunhDanguan.size() > 0) {
                rlDanGuanShow.setVisibility(View.VISIBLE);
                pageAdapter = new PageAdapter(activity, listHunhDanguan, this);
                pageIndor.setTotalPage(listHunhDanguan.size());

                gallery.setAdapter(pageAdapter);

            }
        } else {
            rlDanGuanShow.setVisibility(View.GONE);
        }
    }

    @SuppressLint("HandlerLeak")
    class MyDanguanHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
            getInfoMyview();
            switch (msg.what) {
                case 3:

                    PayForlist();

                    break;
                case 1:

                    // try {
                    //
                    // ischoice_01 = false;
                    // ischoice_02 = false;
                    // ischoice_03 = false;
                    // ivDuijian_01.setVisibility(View.GONE);
                    // ivDuijian_02.setVisibility(View.GONE);
                    // ivDuijian_03.setVisibility(View.GONE);
                    //
                    // tvmainTeam.setTextColor(getResources().getColor(R.color.hall_danguan_team_bg));
                    // tvPingTeam.setTextColor(getResources().getColor(R.color.hall_danguan_team_bg));
                    // tvguestTeam.setTextColor(getResources().getColor(R.color.hall_danguan_team_bg));
                    // tvspfwin.setTextColor(getResources().getColor(R.color.hall_danguan_peiiv_bg));
                    // tvspfflat.setTextColor(getResources().getColor(R.color.hall_danguan_peiiv_bg));
                    // tvspflose.setTextColor(getResources().getColor(R.color.hall_danguan_peiiv_bg));
                    //
                    // rlChoice_01.setBackgroundResource(R.drawable.lr_danguan_input_border);
                    // rlChoice_02.setBackgroundResource(R.drawable.lr_danguan_input_border);
                    // rlChoice_03.setBackgroundResource(R.drawable.lr_danguan_input_border);
                    // lrHallDanguanShow.setVisibility(View.VISIBLE);
                    // tvStopTime.setText("猜中一场就中奖，截至" + hallDanganInfoVo.getStoptime());
                    // tvmainTeam.setText(hallDanganInfoVo.getMainTeam());
                    // tvguestTeam.setText(hallDanganInfoVo.getGuestTeam());
                    // tvspfwin.setText("胜" + hallDanganInfoVo.getSpfwin());
                    // tvspfflat.setText("平" + hallDanganInfoVo.getSpfflat());
                    // tvspflose.setText("负" + hallDanganInfoVo.getSpflose());
                    // tvzs.setText(hallDanganInfoVo.getZs());
                    //
                    // ImageManager.getInstance()
                    // .displayImage(
                    // "http://888.qcai888.cn/Images/Team/"
                    // + removeAllSpace(hallDanganInfoVo.getMainTeam()) + ".png",
                    // ivMainTeam, ImageManager.getViewsHeadOptions());
                    // ImageManager.getInstance()
                    // .displayImage(
                    // "http://888.qcai888.cn/Images/Team/"
                    // + removeAllSpace(hallDanganInfoVo.getGuestTeam()) + ".png",
                    // ivGuestTeam, ImageManager.getViewsHeadOptions());
                    //
                    // if (hallDanganInfoVo.getSpf().equals("3")) {
                    // ivDuijian_01.setVisibility(View.VISIBLE);
                    // rlChoice_01.setBackgroundResource(R.drawable.lr_danguan_input_border_on);
                    // ischoice_01 = true;
                    // strJJMoney = 100 * Double.parseDouble(hallDanganInfoVo.getSpfwin()) + "";
                    // tvmainTeam.setTextColor(getResources().getColor(R.color.white));
                    // tvspfwin.setTextColor(getResources().getColor(R.color.white));
                    // } else if (hallDanganInfoVo.getSpf().equals("1")) {
                    // ivDuijian_02.setVisibility(View.VISIBLE);
                    // rlChoice_02.setBackgroundResource(R.drawable.lr_danguan_input_border_on);
                    // ischoice_02 = true;
                    // strJJMoney = 100 * Double.parseDouble(hallDanganInfoVo.getSpfflat()) + "";
                    // tvPingTeam.setTextColor(getResources().getColor(R.color.white));
                    // tvspfflat.setTextColor(getResources().getColor(R.color.white));
                    // } else if (hallDanganInfoVo.getSpf().equals("0")) {
                    // rlChoice_03.setBackgroundResource(R.drawable.lr_danguan_input_border_on);
                    // ivDuijian_03.setVisibility(View.VISIBLE);
                    // ischoice_03 = true;
                    // strJJMoney = 100 * Double.parseDouble(hallDanganInfoVo.getSpflose()) + "";
                    // tvguestTeam.setTextColor(getResources().getColor(R.color.white));
                    // tvspflose.setTextColor(getResources().getColor(R.color.white));
                    // }
                    //
                    // if (hallDanganInfoVo.getZs().equals("0")) {
                    // ivTuijian_01.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_02.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_03.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_04.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_05.setBackgroundResource(R.drawable.my_start);
                    // } else if (hallDanganInfoVo.getZs().equals("1")) {
                    // ivTuijian_01.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_02.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_03.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_04.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_05.setBackgroundResource(R.drawable.my_start);
                    // } else if (hallDanganInfoVo.getZs().equals("2")) {
                    // ivTuijian_01.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_02.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_03.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_04.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_05.setBackgroundResource(R.drawable.my_start);
                    // } else if (hallDanganInfoVo.getZs().equals("3")) {
                    // ivTuijian_01.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_02.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_03.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_04.setBackgroundResource(R.drawable.my_start);
                    // ivTuijian_05.setBackgroundResource(R.drawable.my_start);
                    // } else if (hallDanganInfoVo.getZs().equals("4")) {
                    // ivTuijian_01.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_02.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_03.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_04.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_05.setBackgroundResource(R.drawable.my_start);
                    // } else if (hallDanganInfoVo.getZs().equals("5")) {
                    // ivTuijian_01.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_02.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_03.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_04.setBackgroundResource(R.drawable.my_start_on);
                    // ivTuijian_05.setBackgroundResource(R.drawable.my_start_on);
                    // }
                    // btnPayOk.setText(GetYujiJJMoney());
                    // // btnPayOk.setText("投10元变" + strJJMoney + "元");
                    // } catch (Exception e) {
                    // // TODO: handle exception
                    // }
                    break;
                case -1:
                    rlDanGuanShow.setVisibility(View.GONE);
                    break;
                case -500:
                    rlDanGuanShow.setVisibility(View.GONE);
                    break;
                default:
                    rlDanGuanShow.setVisibility(View.GONE);
                    break;
            }
            super.handleMessage(msg);
        }

    }

    public String removeAllSpace(String str) {
        String tmpstr = str.replace(" ", "");
        return tmpstr;
    }

    public boolean isMobileNO(String mobiles) {
        Pattern p = Pattern.compile("1[0-9]{10}");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }

    @Override
    public void onCancleClick() {
        // TODO Auto-generated method stub
    }

    @Override
    public void onSureClick() {
        // TODO Auto-generated method stub
        Lottery lottery = new Lottery();
        lottery.setLotteryID("72");
        App.lottery = lottery;

        commitc();
    }

    private void commitc() {

        if (getDanguanList != null) {
            if (getDanguanList.size() > 0) {
                if (App.user != null) {

                    if (numChoice * 200 <= (Double.parseDouble(App.user.getBalance()) + new Double(App.user.getHandselAmount()))) {
                        pd = BaseHelper.showProgress(getActivity(), "", "出票中...", true, false);
                        MyAsynTask myAsynTask = new MyAsynTask();
                        myAsynTask.execute();
                    } else {
                        MyToast.getToast(getActivity(), "余额不足，请先充值！").show();
                        Intent intent_alipay = new Intent();
                        Bundle bundle_alipay = new Bundle();
                        intent_alipay.setClass(context, AmountOfCharge.class);
                        bundle_alipay.putInt("Type", 1);
                        intent_alipay.putExtras(bundle_alipay);
                        context.startActivity(intent_alipay);

                    }
                    // setEnabled(false);

                } else {
                    MyToast.getToast(getActivity(), "请先登陆").show();
                    intent = new Intent(getActivity(), LoginActivity.class);
                    intent.putExtra("loginType", "bet");
                    startActivity(intent);
                }
            }
        } else {
            MyToast.getToast(getActivity(), "请至少选择一注").show();
        }

    }

    class MyAsynTask extends AsyncTask<Integer, Integer, String> {

        String error = "-1";
        long sumCount2 = new Long((long) (numChoice * 2 * 100));

        @Override
        protected String doInBackground(Integer... params) {

            opt = "11";
            time = RspBodyBaseBean.getTime();
            imei = RspBodyBaseBean.getIMEI(getActivity());

            info = RspBodyBaseBean.changeBet_info2("72", "17502", 100, 1, 1, 0, 0, "", "", 2, sumCount2, numChoice, 0, 0,
                    getDanguanList, 1);
            Log.i(TAG, "xiadan" + getDanguanList.toString());
            String key = App.key;
            crc = RspBodyBaseBean.getCrc(time, imei, key, info, App.user.getUid());
            auth = RspBodyBaseBean.getAuth(crc, time, imei, App.user.getUid());
            String[] values = {opt, auth, info};
            Log.i(TAG, "xiadan" + RequestParams.convertParams(getActivity(), opt, info));
            String result = HttpUtils.doPost(App.names, values, App.path);
            System.out.println("xiadan：" + result);
            try {

                JSONObject object = new JSONObject(result);

                error = object.optString("error");
                resultMsg = object.optString("msg");
                if ("0".equals(error)) {
                    dbbalance = object.optDouble("balance");
                    dbfreeze = object.optDouble("freeze");
                    schemeId = object.optString("schemeids");
                    SucJinECost = format.format(object.optDouble("currentMoeny"));
                    SucCaiJinCost = format.format(object.optDouble("currentHandsel"));
                    SuccMoney = format.format(object.optDouble("handselMoney"));

                    // 清空所有数据

                    /*
                     * Intent intent = new Intent(getApplicationContext(),
                     * PaySuccessActivity.class); //viewPagerCurrentIndex = 0;// 过关类型 0.多串1 1.多串多
                     *
                     * intent.putExtra("paymoney", totalMoney); intent.putExtra("currentMoeny",
                     * SucJinECost); intent.putExtra("currentHandsel", SucCaiJinCost);
                     * intent.putExtra("handselMoney", SuccMoney); //intent.putExtra("max_jiangjin",
                     * Utils.decimalFormat((max_jiangjin * AppTools.bei)));
                     * ConfirmselectionActivity.this.startActivity(intent);
                     */

                } else if (error.equals(App.ERROR_MONEY + "")) {
                    LotteryUtils.showMoneyLess(getActivity(), sumCount2);
                } else if (error.equals("-500")) {
                    error = "-500";
                } else if (error.equals("-111")) {
                    error = "-111";
                } else if (error.equals("-110")) {
                    error = "-110";
                } else {

                }
                {

                }
            } catch (JSONException e) {

                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return error;
        }

        @Override
        protected void onPostExecute(String result) {
            hallmyDanguanHandler.sendEmptyMessage(Integer.parseInt(result));
            super.onPostExecute(result);
        }
    }

    @SuppressLint("HandlerLeak")
    class HallDanguanMyHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
            if (pd != null) {
                pd.dismiss();
            }
            switch (msg.what) {
                case 0:
                    // AppTools.lottery.setLotteryID("72");
                    App.schemeId = Integer.parseInt(schemeId);
                    App.user.setBalance(dbbalance);
                    App.user.setFreeze(dbfreeze);
                    PayAsynTask payAsynTask = new PayAsynTask();
                    payAsynTask.execute();

                    break;
                case 1:
                    // Toast.makeText(getActivity(), "购买成功！", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(getActivity(), HallDanguanPaySuccessActivity.class);

                    intent.putExtra("paymoney", new Long((long) (numChoice * 100)));
                    intent.putExtra("currentMoeny", SucJinECost);
                    intent.putExtra("currentHandsel", SucCaiJinCost);
                    intent.putExtra("handselMoney", SuccMoney);

                    startActivity(intent);

                    break;
                case -2:
                    break;
                case -500:
                    MyToast.getToast(getActivity(), "连接超时").show();
                    break;
                case -111:
                    MyToast.getToast(getActivity(), resultMsg).show();
                    break;
                case -110:
                    MyToast.getToast(getActivity(), resultMsg).show();
                    break;
                default:
                    Toast.makeText(getActivity(), "网络异常，购买失败。请重新点击付款购买。", Toast.LENGTH_SHORT).show();
                    break;
            }
            super.handleMessage(msg);
        }
    }

    class PayAsynTask extends AsyncTask<Integer, Integer, String> {

        String error = "-1";

        @Override
        protected String doInBackground(Integer... params) {

            opt = "85";
            time = RspBodyBaseBean.getTime();
            imei = RspBodyBaseBean.getIMEI(getActivity());

            info = RspBodyBaseBean.change_TheSun2(schemeId, "", strJJMoney,
                    listHunhDanguan.get(payPosition).getStoptime(), "1");

            String key = App.key;
            crc = RspBodyBaseBean.getCrc(time, imei, key, info, App.user.getUid());
            auth = RspBodyBaseBean.getAuth(crc, time, imei, App.user.getUid());
            String[] values = {opt, auth, info};
            Log.i(TAG, "晒单" + RequestParams.convertParams(context, opt, info));
            String result = HttpUtils.doPost(App.names, values, App.path);
            System.out.println("晒单：" + result);
            if (result.equals("success")) {
                error = "1";
            } else {
                error = "-1";
            }

            return error;
        }

        @Override
        protected void onPostExecute(String result) {
            hallmyDanguanHandler.sendEmptyMessage(Integer.parseInt(result));
            super.onPostExecute(result);
        }
    }

    @Override
    public void onSureClick(boolean adapterischoice_01, boolean adapterischoice_02, boolean adapterischoice_03,
                            int adapterposition, int adapternum, String adapteryyjj) {
        // TODO Auto-generated method stub

        this.ischoice_01 = adapterischoice_01;
        this.ischoice_02 = adapterischoice_02;
        this.ischoice_03 = adapterischoice_03;

        System.out.println(ischoice_01 + "," + ischoice_02 + "," + ischoice_03);
        numChoice = adapternum;
        strJJMoney = adapteryyjj;
        payPosition = adapterposition;
        if (null == App.user) {
            Toast.makeText(getActivity(), "未登录请先登录！", Toast.LENGTH_SHORT).show();
            intent = new Intent(context, LoginActivity.class);
            startActivity(intent);
        } else {

            if (ischoice_01 || ischoice_02 || ischoice_03) {
                getlistDanguanInfo();
                PaySureDialog = new HallDanguanPaySureDialog(context, this, numChoice * 200 + "");
                Window window = PaySureDialog.getWindow();
                // 可以在此设置显示动画
                WindowManager.LayoutParams wl = window.getAttributes();
                wl.x = 0;
                wl.y = activity.getWindowManager().getDefaultDisplay().getHeight();
                // 以下这两句是为了保证按钮可以水平满屏
                wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
                wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

                window.setWindowAnimations(R.style.mystyle); // 添加动画
                // 设置显示位置
                PaySureDialog.onWindowAttributesChanged(wl);

                PaySureDialog.setCanceledOnTouchOutside(true);// 点击其他区域dialog消失
                PaySureDialog.show();
            } else {
                Toast.makeText(getActivity(), "至少选择一项单关！", Toast.LENGTH_SHORT).show();
            }
        }
    }

    class GetinfoMyAsynTask extends AsyncTask<Integer, Integer, String> {

        String error = "-1";

        @Override
        protected String doInBackground(Integer... params) {

            opt = "105";
            time = RspBodyBaseBean.getTime();
            imei = RspBodyBaseBean.getIMEI(getActivity());

            info = "";
            String key = App.key;
            crc = RspBodyBaseBean.getCrc(time, imei, key, info, App.user.getUid());
            auth = RspBodyBaseBean.getAuth(crc, time, imei, App.user.getUid());
            String[] values = {opt, auth, info};
            Log.i(TAG, "xiadan" + RequestParams.convertParams(getActivity(), opt, info));
            String result = HttpUtils.doPost(App.names, values, App.path);
            Log.e(TAG, "xiadan-----" + result);
            try {
                if (Integer.parseInt(result) <= 0) {
                    App.getInfoNum = "0";
                } else {
                    App.getInfoNum = result;
                }
            } catch (Exception e) {
                // TODO: handle exception
                App.getInfoNum = "0";
            }

            return "0";
        }

        @Override
        protected void onPostExecute(String result) {
            // getinfoMyHandler.sendEmptyMessage(Integer.parseInt(result));
            super.onPostExecute(result);
        }
    }

    @SuppressLint("HandlerLeak")
    class GetinfoMyHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {

            switch (msg.what) {
                case 0:

                    break;

                default:
                    Toast.makeText(getActivity(), "网络异常，购买失败。请重新点击付款购买。", Toast.LENGTH_SHORT).show();
                    break;
            }
            super.handleMessage(msg);
        }
    }

}
